#!/usr/bin/perl 
do 'config.pl';

eval {

   # the directory to dissect pass it in from the command line or default to '.'
    $tmp = $dissect . '/';
    $out = $destination . '/';    # the downloads folder

    # loop through the directory looking for zip archives
    # When we find one extract it to the $tmp dir
    opendir( DIR, $tmp ) || die "Could not open $tmp for reading: $!";
    my @files = readdir(DIR);
    closedir(DIR);

    foreach my $file (@files) {
        next if $file =~ /^\./gi;
        print "Re-archiving $file to $file.zip ...\n";
        my $cmd = "cd $tmp && zip -r $out$file $file";
        `cd $tmp && zip -r $out$file.zip $file`;
    }

    # clean out the tmp folder
    `rm -rf $tmp*`;
  }
